package HomeWork20241025;


// 抽象类 --- 员工类
abstract class Employee {
    protected String name;
    protected int id;
    protected double baseSalary;

    public Employee(String name, int id, double baseSalary) {
        this.name = name;
        this.id = id;
        this.baseSalary = baseSalary;
    }

    public abstract double calculateSalary();
}

// 教师类
class Teacher extends Employee {
    private int teachingHours;
    private int payPerHour;

    public Teacher(String name, int id, double baseSalary, int teachingHours, int payPerHour) {
        super(name, id, baseSalary);
        this.teachingHours = teachingHours;
        this.payPerHour = payPerHour;
    }

    @Override
    public double calculateSalary() {
        return baseSalary + teachingHours * payPerHour;
    }
}

// 实验员类
class LabTechnician extends Employee {
    private int onDutyHours;

    public LabTechnician(String name, int id, double baseSalary, int onDutyHours) {
        super(name, id, baseSalary);
        this.onDutyHours = onDutyHours;
    }

    @Override
    public double calculateSalary() {
        return baseSalary + 20 * onDutyHours;
    }
}

// 行政人员类
class Administrator extends Employee {
    private double allowance;

    public Administrator(String name, int id, double baseSalary, double allowance) {
        super(name, id, baseSalary);
        this.allowance = allowance;
    }

    @Override
    public double calculateSalary() {
        return baseSalary + allowance;
    }
}

class Animals {
    double weight;
    void eat() {
        System.out.println("I can eat anything.");
    }
}
class Fish extends Animals {
    int numberOfFins;
    Fish() {
        numberOfFins = 2; // 通常鱼类有两只鳍
    }
    void swim() {
        System.out.println("I can swim.");
    }
}
class Bird extends Animals {
    int numberOfWings;
    Bird() {
        numberOfWings = 2; // 通常鸟类有两只翅膀
    }
    void fly() {
        System.out.println("I can fly.");
    }
}

public class HomeWork241025
{
    public static void main1(String[] args) {
        Employee teacher = new Teacher("Alice", 101, 3000, 20, 50);
        Employee labTech = new LabTechnician("Bob", 102, 2500, 160);
        Employee admin = new Administrator("Charlie", 103, 2800, 500);

        printSalary(teacher);
        printSalary(labTech);
        printSalary(admin);
    }

    public static void printSalary(Employee employee) {
        System.out.println("Name: " + employee.name + ", Salary: " + employee.calculateSalary());
    }


    public static void main(String[] args) {
        Animals animal = new Animals();
        animal.eat();
        Bird bird = new Bird();
        bird.fly();
        Fish fish = new Fish();
        fish.swim();
    }
}
